-
Notifications
You must be signed in to change notification settings - Fork 782
core/ConfigUtil: Do not normalize objectClass, component.name, component.id configuration values #4109
Conversation
That clearly makes sense! I'm just wondering whether this is the right/only place for this check... On the first glance there also is the In any case, I think putting this assertion into ConfigUtilTest to make sure it doesn't get broken by anybody accidentally would make sense. |
5d15fbd
to
8de991d
Compare
I cannot open projects with groovy code unfortunately, something is misconfigured in my eclipse. I converted one of the test suites to java but converting everything is a little tedious to just have this merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted one of the test suites to java but converting everything is a little tedious
Fully ack, it's great like that, thanks! Better don't repair your IDE then... 😉
@@ -138,8 +135,10 @@ public static Object normalizeType(Object value, ConfigDescriptionParameter conf | |||
for (Entry<String, ?> parameter : configuration.entrySet()) { | |||
String name = parameter.getKey(); | |||
Object value = parameter.getValue(); | |||
ConfigDescriptionParameter configDescriptionParameter = configParams.get(name); | |||
convertedConfiguration.put(name, normalizeType(value, configDescriptionParameter)); | |||
if (!name.equals("objectClass") && !name.equals("component.name") && !name.equals("component.id")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I'm seeing this, I think it would be good to have a static set of strings defined once, then checking here (and above) only if the name is contained in there - just to make sure they don't run out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a private helper method instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, even better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…ent.id configuration values Signed-off-by: David Gräff <david.graeff@web.de>
8de991d
to
e9ea495
Compare
for (Entry<String, Object> parameter : configuration.entrySet()) { | ||
String name = parameter.getKey(); | ||
Object value = parameter.getValue(); | ||
convertedConfiguration.put(name, normalizeType(value)); | ||
if (!isOSGiConfigParameter(name)) { | ||
convertedConfiguration.put(name, normalizeType(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only add the value
to your convertedConfiguration
if it is not an OSGI parameter, is that by intention or is there an
else {
convertedConfiguration.put(name, value);
}
missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's the entire purpose of this PR, to ignore the OSGi parameters completely. They contain either dots so cannot be matched with a variable name or are complex objects, so cannot be marshaled to values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 - these values don't make any sense for the service itself. It knows its name and pid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah Ok, then the name of this PR was a bit misleading for me, because it soudned like you only want to omit the "normalization" and not the entire parameters. thanks for the clarification!
convertedConfiguration.put(name, normalizeType(value, configDescriptionParameter)); | ||
if (!isOSGiConfigParameter(name)) { | ||
ConfigDescriptionParameter configDescriptionParameter = configParams.get(name); | ||
convertedConfiguration.put(name, normalizeType(value, configDescriptionParameter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, don't you want to add an (un-normalized) OSGI parameter to your return map?
Thanks! |
The class
ConfigUtil
is used byConfiguration
to normalize values of a given Map<String,Object> configuration map.I started to use
Configuration
recently also in OSGi services (in the activate and modified method), not only ThingHandlers, which works wonderfully. Except that I get a lot of warnings of the aforementioned class because it tries to normalize "objectClass" which is a complex object.To be able to use the
Configuration
class like in the example below, the "objectClass" and two other OSGi default configuration parameters should be excluded.Signed-off-by: David Gräff david.graeff@web.de